package com.leen.admin.feign.factory;

import com.leen.admin.feign.IAdminFeignClient;
import com.leen.common.vo.ResultEnum;
import com.leen.common.vo.ResultVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.log4j.Log4j2;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;

/**
 * 类说明
 *
 * @author admin
 * @date 2021-05-19
 */
@Log4j2
@Component
public class AdminFeignClientFallbackFactory implements FallbackFactory<IAdminFeignClient> {
    @Override
    public IAdminFeignClient create(Throwable throwable) {
        log.error(throwable);

        return new AdminFeignClientImpl();
    }

    class AdminFeignClientImpl implements IAdminFeignClient{

        @Override
        public ResultVO<String> findByAccount(String account) {
            log.error("IAdminFeignClient中的ResultVO<AdminLoginUserDetails> findByAccount(String {})失败",account);
            return ResultVO.failed(ResultEnum.FEIGN_FALLBACK);
        }
    }
}
